package cn.iocoder.yudao.module.infra.controller.admin.qiniu;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.qiniu.util.QiniuUtil;
import cn.iocoder.yudao.module.infra.controller.admin.qiniu.vo.QiniuTokenReqVO;
import com.sun.net.httpserver.Authenticator;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - qiniu文件")
@RestController
@RequestMapping("/infra/qiniu")
@Validated
public class QiniuController {

    @GetMapping("/token")
    @Operation(summary = "获取上传文件token")
    public CommonResult<String> getToken(){
        String accessKey = "hEhSjJ4vYP2CCVHid4Kka7vLwmdeEj7vCsWYUsGu";
        String secretKey = "bFGhFqbckyc4GWx7HSju8QAu_GKcYUWdw9EPnCNc";
        String bucketName = "dayu-ruoyi";
        String token = QiniuUtil.INSTANCE.CreateToken(accessKey, secretKey, bucketName);

        return success(token);
    }
}
